const HtmlWebpackPlugin = require('html-webpack-plugin')
const path = require('path')
    // 项目的根路径 ngnix
const basePath = __dirname

module.exports = {
    // 打包上下文
    context: path.resolve(basePath, 'src'), // resolve 拼接并验证是否为有效路径 
    resolve: {
        // 要解决的文件类型
        extensions: ['.ts','.tsx','.js']
    },
    entry: {
        app: ['./index.tsx']
    },
    module: {
        // 解觉方案
        rules: [{
            test: /\.tsx?$/,
            exclude: /node_modules/,
            loader: 'babel-loader', // 加载到哪里处理
        }]
    },
    output: {
        // filename: "[name].js",
        filename: '[name].[chunkhash].js' // 生成一个随机hash 
    },
    plugins: [
        new HtmlWebpackPlugin({
            filename: "index.html",
            template: "index.html",
            scriptLoading: "blocking",
        }),
    ]
}